package edu.gdkm.dao;

import edu.gdkm.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserDAO {
    @Select("select * from tb_user where id = #{id}")
    @Results (id = "userMap", value = {
            @Result(property = "id", column = "id"),
            @Result(property = "orders", column = "id",
            many = @Many(select = "edu.gdkm.dao.OrderDAO.findByUserId"))
    })
    User findById(Integer id);
    @Select("select * from tb_user")
    List<User> findAll();
    @Insert("insert into tb_user(username, address) values(#{username}, #{address})")
    boolean save(User user);
    @Update("update tb_user set username = #{username}, address = #{address} where id = #{id}")
    boolean update(User user);
    @Delete("delete from tb_user where id = #{id}")
    boolean delete(Integer id);
}
